package com.moon.utils;

import javax.servlet.http.HttpServletRequest;

public class UserUtils {
    //根据令牌名,从cookie中获取用户对象.
    public static <T> T getCurrUserFromCookie(String tokenName, Class<T> clazz, HttpServletRequest req) {
        String token = CookieUtils.getCookie(tokenName, req);
        return JwtUtils.getObjectWithoutExpValidate(token, clazz);
    }

    //根据令牌名,从请求头中获取用户对象.
    public static <T> T getCurrUserFromHeader(String tokenName, Class<T> clazz, HttpServletRequest req) {
        String token = req.getHeader(tokenName);
        return JwtUtils.getObjectWithoutExpValidate(token, clazz);
    }

    //
}
